﻿@using DemoUserInfo.Models
@using Microsoft.AspNet.Identity
@using Microsoft.AspNet.Identity.EntityFramework
@{
    var currentUserId = User.Identity.GetUserId();
    var manager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()));
    var currentUser = manager.FindById(currentUserId);
}

<div class="form-horizontal simple-form">
    <div class="form-group">
        <div class="col-md-6 control-label">
            <button type="button" class="btn btn-default" data-toggle="modal" data-target="#ChangeAvatar">
                头像
            </button>
        </div>
    </div>
    <div class="form-group">
        <div class="col-md-6  control-label">
            <button type="button" class="btn btn-default" data-toggle="modal" data-target="#ChangeLocation">
                城市
            </button>
        </div>
        <label class="col-md-4 text-left" style="margin-top: 15px">
            @currentUser.Location
        </label>
    </div>
    <div class="form-group">
        <div class="col-md-6 control-label">
            <button type="button" class="btn btn-default" data-toggle="modal" data-target="#ChangeSex">
                性别
            </button>
        </div>

        @switch (currentUser.SexOf)
        {
            case Sex.Female:
                @Html.Label("女", new { @class = "col-md-4 text-left", style = "margin-top: 15px" });
                    break;
                case Sex.Male:
                @Html.Label("男", new { @class = "col-md-4 text-left", style = "margin-top: 15px" });
                    break;
                default:
                @Html.Label("未填写", new { @class = "col-md-4 text-left", style = "margin-top: 15px" });
                    break;
            }
    </div>
</div>





<div class="modal fade" id="ChangeAvatar" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">修改头像</h4>
            </div>
            <div class="modal-body">
                @using (Html.BeginForm("ChangeInfo", "Manage", FormMethod.Post, new { @class = "form-horizontal", role = "form", enctype = "multipart/form-data" }))
                {
                    <div class="form-group">
                        <label for="qFile">选择文件</label>
                        <input type="file" id="qFile" name="qFile">
                        <h4><small>图片大小请不要超过4M。</small></h4>
                        <input class="form-control hidden" name="tape" type="text" value=@UserInfo.Avatar />
                        <input class="form-control hidden" name="newSrc" type="text" />
                    </div>
                    <div class="form-group">
                        <div class="col-md-offset-2 col-md-10">
                            <input type="submit" value="提交" class="btn btn-default" />
                        </div>
                    </div>
                }
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="ChangeLocation" tabindex="-1" role="dialog" aria-labelledby="myModalLabel1">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel1">修改所在地</h4>
            </div>
            <div class="modal-body">
                @using (Html.BeginForm("ChangeInfo", "Manage", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
                {
                    <div class="form-group">
                        <div class="col-md-offset-2 col-md-10">
                            <input class="form-control" data-val="true"
                                   data-val-required="提交不能为空" name="newSrc" type="text" />
                            <input class="form-control hidden" name="tape" type="text" value=@UserInfo.Loaction />
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-offset-6 col-md-6">
                            <input type="submit" value="提交" class="btn btn-default" />
                        </div>
                    </div>
                }
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="ChangeSex" tabindex="-1" role="dialog" aria-labelledby="myModalLabel2">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel2">修改性别</h4>
            </div>
            <div class="modal-body">
                @using (Html.BeginForm("ChangeInfo", "Manage", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
                {
                    <div class="form-group col-md-offset-4 col-md-8">
                        <select class="form-control" name="newSrc">
                            <option value="Male">男</option>
                            <option value="Female">女</option>
                            <option>保密</option>
                        </select>
                        <input class="form-control hidden" name="tape" type="text" value=@UserInfo.Sex />
                    </div>
                    <div class="form-group">
                        <div class="col-md-offset-6 col-md-6">
                            <input type="submit" value="提交" class="btn btn-default" />
                        </div>
                    </div>
                }
            </div>
        </div>
    </div>
</div>